package tk.deep.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * Created by boot on 8/28/15.
 */

@WebListener
public class OnlineRequestListener implements HttpSessionListener {
    private int usrCnt;

    public void sessionCreated(HttpSessionEvent se) {
        usrCnt++;
        se.getSession().getServletContext().setAttribute("usrCnt", usrCnt);
    }

    public void sessionDestroyed(HttpSessionEvent se) {
        usrCnt--;
        se.getSession().getServletContext().setAttribute("usrCnt", usrCnt);
    }
}
